﻿@page "/razor"
@page "/razor1"


@attribute [System.ComponentModel.DataAnnotations.Schema.Table("table")]

@implements IDisposable

@layout Layout.MainLayout


@*
    1. 指令
    2. 运算（表达式）
*@

@x
@{
    var a = 1;
    var b = 2;
    var c = a + b;
}

<h1>C 的值是：@(c)个单位@("Hello World")</h1>

@*
    隐式转换
*@
<p>@DateTime.Now</p>
<p>@DateTime.IsLeapYear(2016)</p>


@*
    显示表澳大使
*@
<p>Last week:@(DateTime.Now - TimeSpan.FromDays(7))</p>


@*
    HTML 字符串
*@
<p>
    @((MarkupString)"<span>Hello World</span>")
</p>


@*
    if..else if ...else
 
@if (true)
{
    <span>这里是 if</span>
}
else if(false)
{
    <span>这里是 else if</span>
}
else
{
    <span>这里是 else if</span>
}

@*
    循环 while, do...while, for, foreach


@while (true)
{
    <span>while 语句</span>
}

@do
{
    <span>do...while 语句</span>
}while(true);

@for(var i = 0; i < 10; i++)
{
    <text>这里是文本@(i)</text>
}
 *@
@* 
@foreach(var item in collection)
{
    
} 
*@

@try
{
    throw new InvalidOperationException("You did something invalid.");
}
catch (Exception ex)
{
    <p>The exception message: @ex.Message</p>
}
finally
{
    <p>The finally statement.</p>
}